import java.util.*;

public class Test {

    static class Student implements Comparable<Student>{
        public String number;
        public String name;
        public int age;

        public Student(String number, String name, int age) {
            this.number = number;
            this.name = name;
            this.age = age;
        }

        public String getNumber() {
            return number;
        }

        public void setNumber(String number) {
            this.number = number;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

 //       @Override
//        public int compareTo(Student o) {
//           if(this.age-o.age<0){
//               return -1;
//           }else if(this.age-o.age>0){
//               return 1;
//           }else{
//               return 0;
//           }
//        }


        @Override
        public int compareTo(Student o) {
            //return o.number.compareTo(this.number);//从大到小
            return this.number.compareTo(o.number);//从小到大
        }

        @Override
        public String toString() {
            return "Student{" +
                    "number='" + number + '\'' +
                    ", name='" + name + '\'' +
                    ", age=" + age +
                    '}';
        }
    }
    public static void main4(String[] args) {
        ArrayList<Student> list=new ArrayList<>();
        //Scanner scan=new Scanner(System.in);
        //String s=scan.nextLine();
        //String m=scan.nextLine();
        //int x=scan.nextInt();
        Student student1=new Student("129","张三",13);
        Student student2=new Student("100","李四",17);
        Student student3=new Student("119","王五",10);
        Student student4=new Student("120","张为",19);
        Student student5=new Student("173","张三强",33);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);
        list.add(student5);
        Collections.sort(list);
        System.out.println(list);
        int sum=0;
        int count=0;
        for (Student student:list){
            String s=student.getName();
            if(s.charAt(0)=='张'){
                sum+=student.getAge();
                count++;
            }
        }
        sum/=count;
        System.out.println("姓张的同学的平均年龄为：");
        System.out.println(sum);
    }
    public static void main3(String[] args) {
        Map<String,Integer> map=new HashMap<>();
        map.put("abc",12345);
        Scanner scan=new Scanner(System.in);
        String s=scan.nextLine();
        int x=scan.nextInt();
        if(map.containsKey(s)&&map.get(s).equals(x)){
            System.out.println("登录成功！！");
        }else{
            System.out.println("登录失败！！");
        }
    }
    public static void main2(String[] args) {
        Scanner scan=new Scanner(System.in);
        String s=scan.nextLine();
        Map<Character,Integer> map=new HashMap<>();
        for (int i = 0; i <s.length(); i++) {
            char ch=s.charAt(i);
            if(map.get(ch)==null){
                map.put(ch,1);
            }else{
                map.put(ch,map.get(ch)+1);
            }
        }
        Set<Map.Entry<Character,Integer>> entrySet=map.entrySet();
        for(Map.Entry<Character,Integer> entry:entrySet){
            System.out.println(entry.getKey()+":"+entry.getValue());
        }
    }
    public static void main1(String[] args) {
        List<Integer> list=new ArrayList<>();
        Random random=new Random();
        for (int i = 0; i <20; i++) {
            list.add(random.nextInt(5));
        }
        System.out.println(list);
        System.out.println();
        Set<Integer> set=new HashSet<>();
        set.addAll(list);
        Collections.sort(list);
        System.out.println(set);
    }
}
